package com.magold.logic.item;

import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.andengine.entity.sprite.AnimatedSprite;
import org.andengine.entity.sprite.AnimatedSprite.IAnimationListener;
import org.andengine.util.modifier.IModifier;

import com.magold.context.IFixedEngine;

public class DisappearListener implements IAnimationListener, IEntityModifierListener {
	private IFixedEngine mEngine;
	
	public DisappearListener(IFixedEngine pEngine) {
		mEngine = pEngine;
	}
	
	@Override
	public void onAnimationStarted(AnimatedSprite pAnimatedSprite, int pInitialLoopCount) { }
	@Override
	public void onAnimationFrameChanged(AnimatedSprite pAnimatedSprite, int pOldFrameIndex, int pNewFrameIndex) { }
	@Override
	public void onAnimationLoopFinished(AnimatedSprite pAnimatedSprite, int pRemainingLoopCount, int pInitialLoopCount) { }
	@Override
	public void onAnimationFinished(AnimatedSprite pAnimatedSprite) {
		mEngine.unregisterChildFromScene(pAnimatedSprite);
	}

	@Override
	public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) { }
	@Override
	public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
		mEngine.unregisterChildFromScene(pItem);
	}
}
